package com.gec.it.util;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Util {
    //MD5加密类
    public static String digest(String pwd){
        try {
            MessageDigest md5 = MessageDigest.getInstance("md5");//md5的加密工具
            byte[] bytes = md5.digest(pwd.getBytes("utf-8"));//md5吃进去的是byte[],返回的也是byte[];
            String s = new BigInteger(1, bytes).toString(16);
            return s;
        }catch (Exception ex){
            throw new RuntimeException(ex);
        }
    }
}
